<style type="text/css">
    .content{
        /* max-width: 400px; */
        margin-top: 20px;
    }
</style>


<div class="content">
    
    <fieldset class="layui-elem-field layui-field-title">
        <br>
        <legend>修改邮箱</legend>
        <blockquote class="layui-elem-quote layui-quote-nm"></blockquote>
        <div class="layui-field-box">
            <form class="layui-form" lay-filter="forgetPasswordFormUsername" style="max-width: 400px;">
                <div class="layui-form-item">
                    <input type="password" id="password" name="password" required lay-verify="required" placeholder="请输入密码"
                        class="layui-input">
                </div>
            
            
                <div class="layui-form-item">
                    <a class="layui-btn layui-btn-fluid layui-btn-normal layui-btn-sm" lay-submit="" id='submit-update'
                        lay-filter="btn_get_v_code">提交并确认修改邮箱</a>
                </div>
            </form>
        </div>
    </fieldset>


    
</div>

        

<script>
    // app.base.loadApi('apiLogin');
    layui.use(['form', 'layer','jquery','laytpl'], function() {
        var form = layui.form;
        var $ = layui.jquery;

        app.base.setTitle('修改邮箱');
        var code= app.parseUrl().params.code
        // 获取基础信息
        app.base.ajaxGet("/api/profile/auth/getUpdateMailInfo/" + code, function (data) {
            var text="你好 "+data.name+",你正在更换绑定的邮箱<a style='color:red'>（"+data.old_mail+" 改为 "+data.new_mail+"）</a>，为了确保是本人操作，需要验证您账号（"+data.username+"）的密码，请谨慎操作！"
            $(".layui-elem-quote").html(text);
        }, function (msg) {
            layer.alert(msg+"，请重新申请")
            $(".content").hide()
        })
        // 提交
        $("#submit-update").click(function(){
            var password= $('#password').val()
            if(password==""){
                layer.msg("请输入密码")
                return
            }
            app.base.ajaxPost("/api/profile/auth/updateMailConfirm/" + code, { password: password }, function () {
                layer.alert("邮箱换绑成功。")
            },function(msg){
                layer.msg("修改失败,"+ msg)
            })
        })
        
     
    });
</script>
